﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DAL_NhaSach;
using BLL_NhaSach;

namespace AppQlyNhaSach.LichSu
{
    public partial class frmLichSuKho : DevExpress.XtraEditors.XtraForm
    {
        LichSuKhoBLL lsBLL;
        public frmLichSuKho()
        {
            InitializeComponent();
        }

        private void frmLichSuKho_FormClosing(object sender, FormClosingEventArgs e)
        {
            frmMainNS.isLSKho = false;
        }

        private void frmLichSuKho_Load(object sender, EventArgs e)
        {
            lsBLL = new LichSuKhoBLL(Properties.Settings.Default.ConnectionStringUser);
            grdLichSu.DataSource = lsBLL.getAllData();
        }

        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            int id = int.Parse(gridView1.GetFocusedRowCellValue("MaLSK").ToString());
            LichSuKho ls =(LichSuKho)lsBLL.findObjects(id);
            txtTen.Text = ls.Sach.TenSach;
            txtNgay.Text = ls.NgayPS.ToShortDateString();
            txtNoBD.Text = ls.SoLuongDau.ToString();
            txtNoPS.Text = ls.SoLuongPS.ToString();
        }
    }
}